package flink.partitioner;

import org.apache.flink.streaming.connectors.kafka.partitioner.FlinkKafkaPartitioner;

import com.alibaba.fastjson.JSONObject;

/**
 * @author ：Jason
 * @date ：Created in 2023/5/5 12:06 PM
 * @description：
 * @modified By：
 * @version: 1.0
 */
public class KafkaPartitioner extends FlinkKafkaPartitioner<JSONObject> {
    @Override
    public int partition(
            JSONObject record, byte[] key, byte[] value, String targetTopic, int[] partitions) {
        return Math.abs(new String(key).hashCode() % partitions.length);
    }
}
